﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using RedDragon.Common.Dtos;
using RedDragon.ERP.API.Application.Commands.BoM;
using RedDragon.ERP.API.Application.Commands.Inventory;
using T.Common.Domain.Common;

namespace RedDragon.ERP.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class InventoryController : ControllerBase
    {
        private readonly IMediator mediator;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator"></param>
        public InventoryController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 物料清单打印
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Result<List<MaterialManagementDto>>> QueryInventory([FromQuery] QueryInventoryCommand cmd)
        {
            return await mediator.Send(cmd);
        }

        /// <summary>
        /// 仓库信息获取
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> GetWarehouse(GetWarehouseCommand cmd)
        {
            return await mediator.Send(cmd);
        }

        /// <summary>
        /// 根据仓库信息获取物料信息
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> GetMaterialManagement(GetMaterialManagementCommand cmd)
        {
            return await mediator.Send(cmd);
        }

        /// <summary>
        /// 审批流程表
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> ProcessFlowEngine(ProcessFlowEngineCommand cmd)
        {
            return await mediator.Send(cmd);
        }
    }
}
